package cn.tedu.costservice.controller;

import cn.tedu.charging.common.pojo.dto.ChargingProcessDTO;
import cn.tedu.charging.common.response.JsonResult;
import cn.tedu.charging.common.pojo.vo.ChargingProcessVO;
import cn.tedu.costservice.service.CostService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@Api(tags = "计费服务")
@Slf4j
@RestController
@RequestMapping("/v1/cost/")
public class CostController {
    @Autowired
    private CostService costService;

    @ApiOperation("计算电费")
    @PostMapping("calcute")
    public JsonResult calculateFee(@RequestBody ChargingProcessDTO chargingProcessDTO){
        log.debug("C1-计费服务:{}",chargingProcessDTO);
        ChargingProcessVO chargingProcessVO=costService.calculateFee(chargingProcessDTO);
        return JsonResult.success(chargingProcessVO);
    }

    /**
     * 获取订单花费
     * @param orderNo
     * @return
     */
    @ApiOperation("获取订单花费")
    @GetMapping("info/{orderNo}")
    public JsonResult getFee(@PathVariable String orderNo){
        log.debug("C2-获取服务:{}",orderNo);
        ChargingProcessVO chargingProcessVO=costService.getInfo(orderNo);
        return JsonResult.success(chargingProcessVO);
    }
}
